<?php

class Controller_Artist extends FLEA_Controller_Action
{
	
	var $smarty;
	
	function Controller_Artist(){
		
	}	

	function actionView(){
		if (isset($_GET['id'])) {
            $artistId = (int)$_GET['id'];
        } else {
            redirect(url());
        }

		$tableAlbums = FLEA::getSingleton('Model_Albums');
		$artistAlbums = $tableAlbums->_getAlbums($artistId);
		
		$this->smarty = &$this->_getView();
		$this->smarty->assign('artistAlbums', $artistAlbums);
		$this->smarty->assign('title', 'aGrindcore');
		$this->smarty->display('tpl_albums.html');
	}

	function actionAdd(){
		
		if (!empty($_POST['artistName'])) {
            $data = array(
				'artist_name' => htmlspecialchars($_POST['artistName'])				
			);
			//print_r($this->artist);
			$tableArtists = FLEA::getSingleton('Model_Artists');
			$tableArtist->create($data);
			
        } else {
            $this->smarty = &$this->_getView();		
			$this->smarty->display('tpl_artist_add.html');
        }

		
	}

	
}
?>